home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH06 / EX6_6.IBM < prev    next >
Encoding:
Text File  |  1996-02-04  |  897 b   |  52 lines

  1. ; IBML Sample program #6.
  2. ; This code compares the execution
  3. ; time of the MUL instruction vs.
  4. ; various shift and add equivalents.
  5.  
  6. #repetitions 480000
  7. #unravel 1
  8.  
  9. ; The following check checks to see how
  10. ; long it takes to multiply two values
  11. ; using the IMUL instruction.
  12.  
  13. #code ("Multiply by 15 using IMUL")
  14. %do
  15.         .286
  16.         mov    cx, 128
  17.         mov    bx, 15
  18. MulLoop1:    mov    ax, cx
  19.         imul    bx
  20.         loop    MulLoop1
  21.  
  22. #endcode
  23.  
  24. ; Do the same test using the extended IMUL
  25. ; instruction on 80286 and later processors.
  26.  
  27. #code ("Multiplying by 15 using IMUL")
  28. %do
  29.         mov    cx, 128
  30. MulLoop2:    mov    ax, cx
  31.         imul    ax, 15
  32.         loop    MulLoop2
  33.  
  34. #endcode
  35.  
  36.  
  37. ; Now multiply by 15 using a shift by four
  38. ; bits and a subtract.
  39.  
  40. #code ("Multiplying by 15 using shifts and sub")
  41. %init
  42. %do
  43.         mov    cx, 128
  44. MulLoop3:    mov    ax, cx
  45.         mov    bx, ax
  46.         shl    ax, 4
  47.         sub    ax, bx
  48.         loop    MulLoop3
  49.  
  50. #endcode
  51. #end
  52.